package Tree;

public class Text {
    public static void main(String[] args) {
        TreeNode node = new TreeNode(new TreeNode(new TreeNode(4),2,null),
                        1,
                        new TreeNode(new TreeNode(6),3,new TreeNode(7)));

        //测试前序递归遍历
        node.preOrder(node);
        System.out.println();

        //测试中序递归遍历
        node.inOrder(node);
        System.out.println();

        //测试后序递归遍历
        node.postOrder(node);
        System.out.println();

        //测试节点个数
        node.size(node);
        System.out.println(node.count);

        //测试叶子节点个数:方法一
        node.getLeafNodeCount1(node);
        System.out.println(node.getLeafNode);

        //测试叶子节点个数:方法二
        System.out.println(node.getLeafNodeCount2(node));

        //测试获取第K层节点数
        System.out.println(node.getKLevelNodeCount(node,1));

        //测试获取最大深度
        System.out.println(node.getHeight(node));

        //寻找对应值的节点
        System.out.println(node.find(node,4));

        //测试层序遍历
        node.levelOrder(node);

        //测试该树是否为完全二叉树
        int high = node.getHeight(node);
        System.out.println(node.isCompleteTree(node,high,1));

        //测试根据前序与中序的遍历序列来构造二叉树
        int[] p = {1,2,4,3,6,7};
        int[] i = {4,2,1,6,3,7};
        TreeNode n = node.prevAndInOrderConstructTree(p, i);
        n.preOrder(n);
        System.out.println();

        //测试根据中序后序的遍历序列来构造二叉树
        int[] post = {4,2,6,7,3,1};
        TreeNode n1 = node.inAndPostConstructTree(i,post);
        n1.preOrder(n1);


    }
}
